package grouuu.layer;

import grouuu.data.Context;
import grouuu.tile.Tiles;
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import openfl.display.Sprite;

/**
 * ...
 * @author Grouuu
 */
class LayerGround extends Sprite
{
	private var context:Context;
	private var tiles:Tiles;
	
	private var oldOriginX:Float = -1;
	private var oldOriginY:Float = -1;

	public function new(context:Context) 
	{
		super();
		
		this.context = context;
		this.tiles = context.tiles;
	}
	
	public function update(originX:Float, originY:Float):Void
	{
		if (originX == oldOriginX && originY == oldOriginY)
			return;
		
		oldOriginX = originX;
		oldOriginY = originY;
		
		graphics.clear();
		
		tiles.drawPart(graphics, originX, originY, context.nbCol, context.nbRow);
	}
}